package com.myapp.struts.reports;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.fill.*;
import java.sql.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.math.*;

public class OriginalStockReport extends HttpServlet implements JRDataSource {

    private int index = -1;
    int data = 0;
    public int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0;
    String fifo, grate, rd, vd;
    Vector v1 = new Vector();
    Vector v2 = new Vector();
    Vector v3 = new Vector();
    Vector v4 = new Vector();
    Vector v5 = new Vector();
    Vector v6 = new Vector();
    Vector v7 = new Vector();
    Vector v8 = new Vector();

    public OriginalStockReport(int data, Vector v1, Vector v2, Vector v3, Vector v4, Vector v5, Vector v6, Vector v7, String rd) {
        this.data = data;
        this.v1 = v1;
        this.v2 = v2;
        this.v3 = v3;
        this.v4 = v4;
        this.v5 = v5;
        this.v6 = v6;
        this.v7 = v7;
        this.rd = rd;
    }

    public boolean next() throws JRException {
        index++;
        return (index < data);
    }

    public Object getFieldValue(JRField field) throws JRException {


        Object value = null;
        String fieldName = field.getName();
        try {



            if ("stock_item".equals(fieldName)) {
                value = v1.elementAt(c1);
                c1++;
            } else if ("stock_location".equals(fieldName)) {
                value = v2.elementAt(c2);
                c2++;
            } else if ("stock_pqty".equals(fieldName)) {
                value = v3.elementAt(c3);
                c3++;
            } else if ("stock_rejected".equals(fieldName)) {
                value = v4.elementAt(c4);
                c4++;
            } else if ("stock_alloc".equals(fieldName)) {
                value = v5.elementAt(c5);
                c5++;
            } else if ("stock_value".equals(fieldName)) {
                value = v6.elementAt(c6);
                c6++;
            } else if ("items_uom".equals(fieldName)) {
                value = v7.elementAt(c7);
                c7++;
            } else if ("from".equals(fieldName)) {
                String[] d1 = rd.split("-");
                String fromDate = d1[2] + "-" + d1[1] + "-" + d1[0];
                value = fromDate;
            }
        } catch (Exception p) {
        }

        return value;
    }
}
